package com.zch.zhongchou.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zch.zhongchou.pojo.Benefittype;
import com.zch.zhongchou.pojo.Projects;
import com.zch.zhongchou.pojo.User;
import com.zch.zhongchou.service.BenefittypeService;
import com.zch.zhongchou.service.ProjectService;
import com.zch.zhongchou.service.UserService;

@Controller
@RequestMapping("ProjectsController")
public class ProjectsController {
	@Autowired
	private ProjectService ps;
	@Autowired
	private UserService us;
	@Autowired
	private BenefittypeService bfts;
	@RequestMapping("getProjectsDetail")
	public String getProjectsDetail(int id,HttpServletRequest request){
		//根据id得到项目信息
		Projects projects = ps.getProjectById(id);
		//获得申请人的id
		int usId = projects.getPsUsId();
		//获得众筹的公益类型id
		int bt = projects.getPsBftpId();
		//获得申请人信息
		User user = us.getUserById(usId);
		//获得公益类型的信息
		Benefittype benefittype = bfts.getBenefittypeById(bt);
		//将参数存入作用域
		request.setAttribute("projects", projects);
		request.setAttribute("user", user);
		request.setAttribute("benefittype", benefittype);
		return "admin/product/product-info1";
	}
}
